package com.sunwayhorizo.health.common.convertXMLFromObject;

import com.sunwayhorizo.health.business.dto.clinic.orders.SubstanceAdmtDTO;

/**
 * 解析对象公布的工具类
 */
public class ParseObjectToXML
{
    private Parse parse = null;
    private BaseTypeUtil baseTypeUtil = null;

    public ParseObjectToXML()
    {
        if (this.parse == null)
        {
            this.baseTypeUtil = new BaseTypeUtil();
            this.parse = new Parse(this.baseTypeUtil);
        }
    }

    public String converXmlFromObject(Object obj) throws Exception
    {
        return this.parse.getXml(obj);
    }

    public String getDateFormat()
    {
        return this.parse.getDateFormat();
    }

    /**
     * 日期类型，如 yyyy-MM-dd HH:mm:ss
     * 
     * @param dateFormat
     */
    public void setDateFormat(String dateFormat)
    {
        this.parse.setDateFormat(dateFormat);
    }

    public String getXMLHeader()
    {
        return this.parse.getXMLHeader();
    }

    /**
     * 设置xml头
     * 
     * @param header
     */
    public void setXMLHeader(String header)
    {
        this.parse.setXMLHeader(header);
    }

    public boolean isShowListFlag()
    {
        return this.parse.isShowListFlag();
    }

    /**
     * 若是空list，是否显示list成员变量的名称
     * 
     * @return
     */
    public void setShowListFlag(boolean showListFlag)
    {
        this.parse.setShowListFlag(showListFlag);
    }

    /**
     * 这是一个Demo，对SubstanceAdmtDTO进行xml转换并打印
     * @param args
     */
    public static void main(String[] args) throws Exception
    {
        ParseObjectToXML parseObjectToXml = new ParseObjectToXML();
        System.out.println(parseObjectToXml.converXmlFromObject(new SubstanceAdmtDTO()));
    }
}
